package lib.self.fresco;

import android.content.Context;
import android.net.Uri;
import androidx.annotation.DrawableRes;
import android.util.AttributeSet;

import com.facebook.drawee.generic.GenericDraweeHierarchy;

import lib.self.fresco.photo.PhotoDraweeView;

/**
 * description: 加载图片控件 支持放大缩小
 * author: Steven Xiao
 * date: 2017/4/27
 */
public class NetworkPhotoView extends PhotoDraweeView {

    public NetworkPhotoView(Context context, GenericDraweeHierarchy hierarchy) {
        super(context, hierarchy);
    }

    public NetworkPhotoView(Context context) {
        super(context);
    }

    public NetworkPhotoView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public NetworkPhotoView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public void load(String url) {
        load(url, 0);
    }


    public void load(String url, @DrawableRes int placeHolderRid) {
        Uri uri = Uri.parse(url);
        setPhotoUri(uri);
        if (placeHolderRid != 0) {
            getHierarchy().setPlaceholderImage(placeHolderRid);
        }
    }

}
